package by.artureg.so.smd;


import by.artureg.so.conf.ConfLoader;
import by.artureg.so.conf.Report;
import by.artureg.so.dl.SoService;
import by.artureg.so.ex.SoException;
import by.artureg.so.to.ColumnTo;
import by.artureg.so.to.ParamTo;
import com.opensymphony.xwork2.Action;
import org.apache.struts2.json.annotations.SMDMethod;
import org.springframework.stereotype.Component;

import javax.inject.Inject;
import java.util.List;

@Component
public class SmdService {
    public String smd() {
        return Action.SUCCESS;
    }

    @Inject
    private SoService service;

    @SMDMethod
    public List<List<ColumnTo>> runReport(String reportName, List<ParamTo> values) throws SoException {
        return service.runReport(reportName, values);
    }

    @SMDMethod
    public List<Report> getReports() throws SoException {
        return ConfLoader.load().getReports();
    }
}
